package second.thread;

import java.util.concurrent.Callable;

/**
 * @Author: heweiwei
 * @Date: 2/8/25 PM2:45
 * @Description:
 */
// 实现 Callable 接口，用于定义可返回结果的任务
public class Task implements Callable<Integer> {

    private final int taskId;

    public Task(int taskId) {
        this.taskId = taskId;
    }

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName()+" start");
        // 模拟耗时操作
        Thread.sleep(3000);
        // 返回任务的 ID 作为结果
        System.out.println(Thread.currentThread().getName()+" end");
        return taskId;
    }
}
